<?php echo $javascript->link('scriptaculous-js-1.8.3/lib/prototype.js'); ?>
<?php echo $javascript->link('scriptaculous-js-1.8.3/src/scriptaculous.js'); ?>
<?php echo $javascript->link('popup/popup.js'); ?>
<div class="pondcases index">
<h2><?php __('Pondcases');?></h2>
<table cellpadding="0" cellspacing="1" width="100%">
  <tr align="center">
    <td width="10%" height="35" bgcolor="<?php echo $pondcases->getColor(3); ?>"><b><?php echo $this->Html->link('Mar',array('controller' => 'pondcases', 'action' => 'index2', '?' => array('id' => 3))); ?></b></td>
    <td width="10%" bgcolor="<?php echo $pondcases->getColor(4); ?>"><b><?php echo $this->Html->link('Apr',array('controller' => 'pondcases', 'action' => 'index2', '?' => array('id' => 4))); ?></b></td>
    <td width="10%" bgcolor="<?php echo $pondcases->getColor(5); ?>"><b><?php echo $this->Html->link('Mai',array('controller' => 'pondcases', 'action' => 'index2', '?' => array('id' => 5))); ?></b></td>
    <td width="10%" bgcolor="<?php echo $pondcases->getColor(6); ?>"><b><?php echo $this->Html->link('Jun',array('controller' => 'pondcases', 'action' => 'index2', '?' => array('id' => 6))); ?></b></td>
    <td width="10%" bgcolor="<?php echo $pondcases->getColor(7); ?>"><b><?php echo $this->Html->link('Jul',array('controller' => 'pondcases', 'action' => 'index2', '?' => array('id' => 7))); ?></b></td>
    <td width="10%" bgcolor="<?php echo $pondcases->getColor(8); ?>"><b><?php echo $this->Html->link('Aug',array('controller' => 'pondcases', 'action' => 'index2', '?' => array('id' => 8))); ?></b></td>
    <td width="10%" bgcolor="<?php echo $pondcases->getColor(9); ?>"><b><?php echo $this->Html->link('Sep',array('controller' => 'pondcases', 'action' => 'index2', '?' => array('id' => 9))); ?></b></td>
    <td width="10%" bgcolor="<?php echo $pondcases->getColor(10); ?>"><b><?php echo $this->Html->link('Okt',array('controller' => 'pondcases', 'action' => 'index2', '?' => array('id' => 10))); ?></b></td>
    <td width="10%" bgcolor="<?php echo $pondcases->getColor(11); ?>"><b><?php echo $this->Html->link('Nov',array('controller' => 'pondcases', 'action' => 'index2', '?' => array('id' => 11))); ?></b></td>
    <td width="10%" bgcolor="<?php echo $pondcases->getColor(12); ?>"><b><?php echo $this->Html->link('Dez',array('controller' => 'pondcases', 'action' => 'index2', '?' => array('id' => 12))); ?></b></td>
  </tr>
</table>
<table cellpadding="0" cellspacing="0" width="100%">
  <tr height="25">
	<th width="100">&nbsp;Case</th>
	<th width="100">&nbsp;Account</th>
	<th width="200">&nbsp;Createdate</th>
	<th width="100">&nbsp;Aging</th>
	<th width="100">&nbsp;Anz.POND</th>
	<th width="100">&nbsp;BadPayer</th>
	<th width="140">&nbsp;FutureDate</th>
	<th class="actions">&nbsp;Actions</th>
	<th width="300" colspan="2">&nbsp;Comment</th>
  </tr>
  <?php
  $i = 0;
  $counter = 1;
  foreach ($result as $r):
	  $class = null;
	  if ($i++ % 2 == 0) {
	  	  $class = ' class="altrow2"';
	  }
	  else { $class = ' class="altrow"'; }
	  $div = "field".$counter;
	  $mousediv = "mouse".$counter;
  ?>
  <tr<?php echo $class;?> height="20">
	<td>&nbsp;<?php echo $r['pc']['caseid']; ?></td>
	<td>&nbsp;<?php echo $r['c']['accountnumber']; ?></td>
	<td>&nbsp;<?php echo $r['pc']['createdate']; ?></td>
	<td>&nbsp;<?php echo $pondcases->getAging($r['pc']['createdate']); ?></td>
	<td>&nbsp;<?php echo $pondcases->getCountPONDCases($r['c']['mac']); ?></td>
	<td>&nbsp;<?php IF($r['c']['role'] == "Bad Payer") { echo "yes"; } ELSE { echo "no"; } ?></td>
	<td>&nbsp;<?php echo $r['pc']['futuredate']; ?></td>
	<td class="actions">
	  <div id="<?php echo $div; ?>" name="<?php echo $div; ?>" style="float:left;">
	  <?php IF($r['pc']['status'] == 33) { ?>
	  <?php echo $ajax->link('Process', array('controller' => 'pondcases', 'action' => 'process', '?' => array('caseid' => $r['pc']['id'], 'div' => $div)), array('update' => $div)); ?>
	  <?php echo " - "; ?>
	  <?php echo $ajax->link('POD', array('controller' => 'pondcases', 'action' => 'pod', '?' => array('caseid' => $r['pc']['id'], 'div' => $div)), array('update' => $div)); ?>
	  <?php echo " - "; ?>
	  <?php echo $ajax->link('Services churned', array('controller' => 'pondcases', 'action' => 'churned', '?' => array('caseid' => $r['pc']['id'], 'div' => $div)), array('update' => $div)); ?>
	  <?php echo " - "; ?>
	  <?php echo $ajax->link('Order cancelled', array('controller' => 'pondcases', 'action' => 'ordercancelled', '?' => array('caseid' => $r['pc']['id'], 'div' => $div)), array('update' => $div)); ?>
	  <?php }
	  ELSE {
	      IF($r['pc']['status'] == 34) { echo "&nbsp;Swap created - New PR: "; echo $pondcases->getNewPR($r['pc']['id']); }
	      IF($r['pc']['status'] == 36) { echo "&nbsp;Service churned"; }
	      IF($r['pc']['status'] == 37) { echo "&nbsp;Swap closed"; }
	      IF($r['pc']['status'] == 42) { echo "&nbsp;Order cancelled"; }
	  } ?>
	  </div>
	</td>
	<td align="center">&nbsp;
	  <?php
	  IF($pondcases->searchForComment($r['pc']['id']) > 0){ ?>
	    	<a href="" onmouseover="popup('<?php echo $pondcases->getComment($r['pc']['id']); ?>','beige')" onmouseout="kill()">View</a>
	  <?php  }
	  ?>
	</td>  
	<td>&nbsp;
	  <?php
	    IF($pondcases->searchForComment($r['pc']['id']) > 0){
	    	echo $ajax->link('Update', array('controller' => 'comments', 'action' => 'add2', '?' => array('caseid' => $r['pc']['id'], 'div' => $div, 'stat' => 1)), array('update' => $div));
	    }
	    ELSE {
	        echo $ajax->link('Add', array('controller' => 'comments', 'action' => 'add2', '?' => array('caseid' => $r['pc']['id'], 'div' => $div, 'stat' => 0)), array('update' => $div));
	    }
	  ?>
	</td>
  </tr>
  <?php $counter++; ?>
  <?php endforeach; ?>
  <?php
  foreach ($result2 as $r2):
	  $class = null;
	  if ($i++ % 2 == 0) {
	  	  $class = ' class="altrow2"';
	  }
	  else { $class = ' class="altrow"'; }
	  $div = "field".$counter;
	  $mousediv = "mouse".$counter;
  ?>
  <tr<?php echo $class;?> height="20">
	<td>&nbsp;<?php echo $r2['pc']['caseid']; ?></td>
	<td>&nbsp;<?php echo $r2['c']['accountnumber']; ?></td>
	<td>&nbsp;<?php echo $r2['pc']['createdate']; ?></td>
	<td>&nbsp;<?php echo $pondcases->getAging($r2['pc']['createdate']); ?></td>
	<td>&nbsp;<?php echo $pondcases->getCountPONDCases($r2['c']['mac']); ?></td>
	<td>&nbsp;<?php IF($r2['c']['role'] == "Bad Payer") { echo "yes"; } ELSE { echo "no"; } ?></td>
	<td>&nbsp;<?php echo $r2['pc']['futuredate']; ?></td>
	<td class="actions">
	  <div id="<?php echo $div; ?>" name="<?php echo $div; ?>" style="float:left;">
	  <?php IF($r2['pc']['status'] == 33) { ?>
	  <?php echo $ajax->link('Process', array('controller' => 'pondcases', 'action' => 'process', '?' => array('caseid' => $r2['pc']['id'], 'div' => $div)), array('update' => $div)); ?>
	  <?php echo " - "; ?>
	  <?php echo $ajax->link('POD', array('controller' => 'pondcases', 'action' => 'pod', '?' => array('caseid' => $r2['pc']['id'], 'div' => $div)), array('update' => $div)); ?>
	  <?php echo " - "; ?>
	  <?php echo $ajax->link('Services churned', array('controller' => 'pondcases', 'action' => 'churned', '?' => array('caseid' => $r2['pc']['id'], 'div' => $div)), array('update' => $div)); ?>
	  <?php echo " - "; ?>
	  <?php echo $ajax->link('Order cancelled', array('controller' => 'pondcases', 'action' => 'ordercancelled', '?' => array('caseid' => $r2['pc']['id'], 'div' => $div)), array('update' => $div)); ?>
	  <?php }
	  ELSE {
	      IF($r2['pc']['status'] == 34) { echo "&nbsp;Swap created - New PR: "; echo $pondcases->getNewPR($r2['pc']['id']); }
	      IF($r2['pc']['status'] == 36) { echo "&nbsp;Service churned"; }
	      IF($r2['pc']['status'] == 37) { echo "&nbsp;Swap closed"; }
	      IF($r2['pc']['status'] == 42) { echo "&nbsp;Order cancelled"; }
	  } ?>
	  </div>
	</td>
	<td>&nbsp;
	  <?php
	  IF($pondcases->searchForComment($r2['pc']['id']) > 0){ ?>
	    	<a href="" onmouseover="popup('<?php echo $pondcases->getComment($r2['pc']['id']); ?>','beige')" onmouseout="kill()">View</a>
	  <?php  }
	  ?>
	</td>  
	<td>&nbsp;
	  <?php
	    IF($pondcases->searchForComment($r2['pc']['id']) > 0){
	    	echo $ajax->link('Update', array('controller' => 'comments', 'action' => 'add2', '?' => array('caseid' => $r2['pc']['id'], 'div' => $div, 'stat' => 1)), array('update' => $div));
	    }
	    ELSE {
	        echo $ajax->link('Add', array('controller' => 'comments', 'action' => 'add2', '?' => array('caseid' => $r2['pc']['id'], 'div' => $div, 'stat' => 0)), array('update' => $div));
	    }
	  ?>
	</td>
  </tr>
  <?php $counter++; ?>
  <?php endforeach; ?>
</table>

</div>